package com.yzd.learnjava.containers;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.Vector;

import com.yzd.learnjava.util.Print;

public class Utilities {
	static List<String> list = Arrays.asList("one two three foyr five six one".split(" "));
	public static void main(String[] args) {
		Print.print(list);
		Print.print("'List' disjoin (four)? : " + Collections.disjoint(list, Collections.singletonList("Four")));
		Print.print("max : " + Collections.max(list));
		Print.print("min : " + Collections.min(list));
		Print.print("max w/ comparator  : " + Collections.max(list, String.CASE_INSENSITIVE_ORDER));
		Print.print("min w/ comparator  : " + Collections.min(list, String.CASE_INSENSITIVE_ORDER));
		
		List<String> subList = Arrays.asList("four five six".split(" "));
		Print.print("index of subList : " + Collections.indexOfSubList(list, subList));
		Print.print("lastindex of subList : " + Collections.lastIndexOfSubList(list, subList));
		
		Collections.replaceAll(list, "one", "yo");
		Print.print("replaceAll : " + list);
		Collections.reverse(list);
		Print.print("reverse : " + list);
		Collections.rotate(list, 3);
		Print.print("rotate : " + list);
		
		List<String> source = Arrays.asList("in the matrix".split(" "));
		Collections.copy(list, source);
		Print.print("copy : " + list);
		Collections.swap(list, 0, list.size() - 1);
		Print.print("swap : " + list);
		Collections.shuffle(list);
		Print.print("shuffle : " + list);
		Collections.fill(list, "pop");
		Print.print("fill : " + list);
		Print.print("frquency of 'pop' : " + Collections.frequency(list, "pop"));
		
		List<String> dups = Collections.nCopies(3, "snap");
		Print.print("dups : " + dups);
		Print.print("list disjoint 'dups' ? : " + Collections.disjoint(list, dups));
		
		Enumeration<String> e = Collections.enumeration(dups);
		Vector<String> v = new Vector<String>();
		while(e.hasMoreElements()) {
			v.add(e.nextElement());
		}
		ArrayList<String> arrayList = Collections.list(v.elements());
		Print.print("arrayList : " + arrayList);
	}
}
